package com.tongtong.controller;

import com.tongtong.task.MumudaTimerTask;
import com.tt.task.MethodTaskInfo;
import com.tt.task.ProdPlanSimTaskUtils;
import com.tt.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Title: TimerTaskController
 * @Author zl
 * @Package com.tongtong.controller
 * @Date 2025/7/30 17:25
 * @description: 定时任务controller
 */
@RestController
@RequestMapping("timerTask")
public class TimerTaskController {
    @Autowired
    private MumudaTimerTask mumudaTimerTask;
    @Autowired
    private ProdPlanSimTaskUtils prodPlanSimTaskUtils;

    @GetMapping("/startTask")
    public R startTask(){
        //开启定时器
        MethodTaskInfo methodTaskInfo = new MethodTaskInfo(mumudaTimerTask,"checkFile");
        String taskId = "channel-task";
        prodPlanSimTaskUtils.createTask(methodTaskInfo,"0/10 * * * * ?",taskId);
        return R.ok();
    }

    @GetMapping("/stopTask")
    public R stopTask(){
        //停止定时器
        prodPlanSimTaskUtils.stopTask("channel-task");
        return R.ok();
    }


}
